home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 9
/
Commodore_Free_Issue_09_2007_Commodore_Computer_Club.d64
/
t.shredz64 2
< prev
next >
Wrap
Text File
|
2023-02-26
|
11KB
|
347 lines
u The Shredz64 Project
By Toni Westbrook
PART 2
After a hefty debugging session, the
physical adapter is solid and works
great with both a guitar controller
and normal dual shock controller. It
was amazing to try all my old games
with a PS2 controller (as well as some
Amiga games and Atari 2600, haven't
tried the Sega Master System yet).
Also, I've started writing the actual
Shredz64 (guitar hero) game for the
C64. I started out with a simple
debugging routine to show the status
of what guitar buttons were being
pressed. Here are two screenshots
(literally) of the C64 reporting whats
happening on both the fret board and
strum bar/lift sensor:
While this program was written in
BASIC, the final Shredz64 program is
being written in a combination of C
and 6502 assembly using the CC65 cross
compiler, which I got up and running a
few days ago. I'm currently developing
in an emulator environment and am
waiting for parts to arrive to build a
cable to transfer the program to the
C64 itself for testing.
Anyway, so much more to come, but
things are progressing nicely! I've
found out that this project is
featured in Engadget which is great, I
hope to be making updates more
regularly now that I know people are
reading. If you have any questions,
feel free to email me: twestbrook AT
synthdreams DOT com. Huzzah!
1/10/07 - 1/11/07 I recently ordered
the arduino development board - it's a
programming board for the ATMEGA8
microcontroller with a built in USB
interface. It was extremely cheap 35
for the board, 3 bucks per ATMega8
chip). The IDE allows you to program
in C code and upload it straight to
the flash memory on the ATMega, which
is called by the bootloader on
startup. The ATMega8 is awesome for 3
bucks, it runs at 16mhz, has 1K RAM,
8K flash memory, and 512 bytes of
EEPROM memory. Great for a project
like this. HOW DOES THIS RELATE TO THE
GUITAR HERO CONTROLLER?
Well, long gone are the days when a
joystick simply put voltage over a
line to indicate a button being
pressed. This is true on
Atari/Commodore/Sega/Amiga
controllers, but nothing recent. Back
in the day, if you pressed LEFT, a
circuit to a specific pin would be
completed on the 9 pin connector.
Press up, a different pin would be
connected. A pin for every button, it
was an easy life. But now PSX, XBOX,
GC controllers have a billion buttons
and only a limited number of lines, so
they encode the data into a serial
stream of packets, just like if you
were sending data over a serial
connection or network. In comes the
ATMega8 microcontroller. The atmega
receives the serial stream of packets,
decodes them and figures out which
buttons are being pressed. It then
drops voltage on corresponding lines
to the output to the commodore. But
before I did that I had to test to
make sure my decoding program was
working! THIS WAS A NEAT TEST.
First I took a PSX extender cable: I
opened the male connector and got the
pins out. I continuity tested each
line so I could figure out which color
was which pin. I then connected these
pins into a solderless protoboard and
mapped arbitrary pins off the arduino
board into the protoboard. I also
hooked a tiny loudspeaker up to the
protoboard too and mapped the arduino
into it. The goal to test this guy out
was to have the ATMega play sounds on
the speaker when I strummed with
buttons held down on the guitar.
Then was the task of writing the
decoder in C. I found some docs online
that describe the protocol the PSX
controller uses. It basically consists
of sending data over a COMMAND line,
listening on the DATA line,
manipulating the CLOCK line to drive
the data, checking the ACK line for
good measure (not really necessary),
and dropping the ATTENTION line when
it was time to wake the controller up.
The prototal was the following. Drop
the attention line, Send 0x01 over the
COMMAND line to the controller, the
arduino should receive 0xFF back on
the data line. Then the controller is
sent 0x42 which is a REQUEST FOR DATA
command, at the same time the
controller responds back with what
mode it is in (Digital or Analog,
mouse or whatever). It then sends back
0x5A to indicate "Here comes the data
SUCKA", and then sends 2-7 bytes
depending on if the controller is in
digital or analog mode. Those bytes
contain a bit for each button, either
set to 0 or 1 depending on if the
button is pressed or not.
It took about two days to get this
working, one because I needed to add a
10K pullup resistor across the COMMAND
pin as the arduino was polling the
controller too fast and the line noise
was crapping out any packets I was
sending. I found this tip online by
someone who had done another PSX
controller project. The other was I
wasn't reading and writing data
properly with the clock cycle, I was
doing more on the rise of the clock
and I needed to do things on the fall
of the clock. It was frustrating, but
eventually I got it working. I then
wrote a quick program to print out to
my laptop (via the USB serial link)
what button was being pressed, then I
pressed each button on the guitar
controller and saw what the
corresponding PSX button was. Here's
THAT:
Green = R2
Red = O
Yellow = Triangle
Blue = X
Orange = Square
Start = Start
Select = Select Lift
guitar up = L2 Strum
up = UP Strum
down = DOWN
I couldn't test the whammy bar out as
I know for a fact it manipulates one
of the analog sticks, and I don't know
the command yet to force a controller
into analog mode, so the guitar starts
up in digital mode and disables the
whammy bar.
Anyway, I got the decoder working, and
using the button map data, I created a
little program for the atmega that
plays a note through the loudspeaker
when the strum bar is hit depending on
what key combination is held down
during the strum. It basically assigns
a frequency value to each key, then
adds them together, and plays that.
It's not aligned to real notes right
now, I did it more for just a fun test
to actually see the thing working.
There really is no other steps between
here and hooking it to the commodore
64 other than wiring up a DB9
conector.
That's it for now! Soon the interface
will be done and it will be time to
start on the game.
The Interface The PSX64 interface
connects playstation controllers to
computers that use a DB9 port and C64
pin configuration (such as the Amiga,
Atari 2600, Sega Master System, etc).
Additionally, if a guitar controller
is detected, it will encode strum up,
strum down, lift up, and the whammy
bar onto the two potentiometer lines
of the joystick port. While this extra
guitar functionality is usable by the
Shredz64 game only (and any future
projects), the normal functionality of
the PSX64 interface can be used with
any game, and works well!
The PSX64 features the following:
1. The aforementioned ability to hook
a playstation controller up to a DB9
joystick computer. It maps up, down,
left, right and X on the PSX
controller to up, down, left, right,
and fire on the computer,
respectively.
2. If the playstation controller is
put into analog mode, it will also map
over the left analog control stick to
the 4 up/down/left/right directions.
3. On a normal playstation controller,
if the start button is pressed, the
PSX64 goes into programming mode. The
user can then hit L1, L2, R1, or R2,
and program up to 127 buttons in for a
macro mapped to that button. Hitting
start again ends programming mode and
saves the macro. These macros are
saved in the PSX64's EEPROM and will
be retained after power off.
4. If a guitar is plugged in, the
PSX64 goes into guitar mode and maps
the fretboard buttons into up, down,
left, right, and fire. It encodes
strum up, strum down, and lift up into
one of the POT lines. It encodes the
value of the whammy bar into the other
POT line.
5. The PSX64 uses a socket mounted
ATMega8 microcontroller, flashable
with firmware updates with easy to
build programmers. It makes use of two
digital potentiometers for accurate
strum and whammy encoding. It does
require a 9v-15v DC power supply to
operate.
Shredz64 the game Shredz64 is (will be
if successful!) a game for the
Commodore 64 that makes use the
playstation guitar controller hooked
through the PSX64 interface. It is in
the beginning stages right now, with
only button testing and some graphics
routines done, but is on a steady
track. There is a good chance Shredz64
will make use of SID and/or MID files
for its music, though with channel
constraints,
SID files are more likely than MIDI
files off the bat. Some obstacles to
be worked through include presentation
of music given the 3 voice nature of
the 6581 and 8580. Calculation,
whether static or dynamic, of fret
button mappings to notes as well.
Also, efficiency needed for quick
polling of the guitar controller.
I'm keeping the graphics very simple,
confined to PETSCII and sprites during
the early phases, since I want to save
all the processing power I can for the
music and response. If I have some
extra cycles left over at the end,
I'll tweak and polish up the graphics.
Anyway, you can see the (very)
beginnings of how the main screen will
look.
Why do it Ha, this seems to be a
question I get a lot. In December of
2006, I attended the TPUG World of
Commodore convention in Toronto,
Canada, and found hundreds of people
still very much interested in the
Commodore 64 and expanding its
capabilities, even today. I saw some
awesome demos of people building
network adapters, online games, MIDI
interfaces, and other cool stuff for
their C64s.
I fell in love with the idea - I love
the C64 and I love hacking around with
software and hardware alike, so I
figured this would be the perfect
project! Around the same time I had
also read about Jeri Ellsworth and her
amazing work and success with
recreating the C64, and I was just
really inspired all around. If all
goes well, perhaps I can present my
little project at next years TPUG
conference!
Really, when it comes right down to
it, I work on "more serious" projects
all the time, for my day job, for
private contracts, all the time. They
pay the bills, and I do enjoy them,
but I also like to do fun, wacky
stuff. We live in a world where a
computer older than 6-7 is considered
useless, let alone 25 years. Well, I
absolutely love my Commodore 64, it
has a lot of meaning and memories for
me, and I love doing fun things with
it - and there's no reason why it
can't do a lot of cool things, even
still. You don't always need a piece
of equipment that can perform 4
billion calculations per second,
sometimes 1 million is more than
enough. Plus, come on, hooking a
playstation guitar up to a Commodore
64 is just damn cool. ;)
For more information head over to the
SHEDZ64 website
http://freedomirc.net/{$fe}megaboz/shredz6
4/
...end...
www.commodorefree.com